import axios from 'axios';

import nProgress  from 'nprogress';

import "nprogress/nprogress.css"

const mockReq = axios.create({
    baseURL:"/mock",
    timeout: 10000
});

//配置当前axios的请求拦截器
mockReq.interceptors.request.use(
    
    (config) => {
        //当请求发送的时候，激活进度条
        nProgress.start()
        return config
    },
    (err) => {
        return Promise.reject(err.message);
    }
);

//配置当前axios的响应拦截器
mockReq.interceptors.response.use(
   
    (response) => {
        nProgress.done();
        return response.data.data
    },
    (err) => {
        return Promise.reject(err.message)
    }
)


export default mockReq